package com.huitone.gddw.utils;

import javax.servlet.http.HttpSession;

import com.huitone.gddw.dao.entity.Users;

/**
 * 工具类
 * @author wuluodan
 *
 */
public class ResourceUtil {

	/**
	 * 获取session用户
	 * @return Users
	 */
	public static final Users getSessionUser() {
		HttpSession session = ContextHolderUtils.getSession();
		if (!StringUtils.isEmpty(session.getId()) && ContextHolderUtils.getSession().getAttribute("curLoginUser") != null) {
			return (Users)ContextHolderUtils.getSession().getAttribute("curLoginUser");
		}
		return null;
	}
	
	/**
	 * 判断session用户是否为管理员
	 * @return Users
	 */
	public static final Boolean isAdmin() {
		HttpSession session = ContextHolderUtils.getSession();
		if (!StringUtils.isEmpty(session.getId()) && ContextHolderUtils.getSession().getAttribute("curLoginUser") != null) {
			return (Boolean)ContextHolderUtils.getSession().getAttribute("isAdmin");
		}
		return false;
	}
	
}
